package com.srd.phone.mvp.presenters;

import android.graphics.Color;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.style.AbsoluteSizeSpan;
import android.text.style.ForegroundColorSpan;
import android.widget.TextView;

import com.android.volley.RequestQueue;
import com.srd.phone.bean.TenderInfo;
import com.srd.phone.mvp.interfaces.IBaseView;

public class TenderInvestPresenter extends BasePresenter {

    public TenderInvestPresenter(RequestQueue requestQueue0, IBaseView iView0) {
        super(requestQueue0, iView0);
    }

    public String getFormatMoney(double value) {
        if (value < 10000) {
            return value + "元";
        } else {
            double d = value / 10000;
            return d + "万元";
        }
    }

    /**
     * 未满标
     */
    public void setTenderTextSpan(TextView tv, String... strs) {
        String value = strs[0];
        SpannableString sb = new SpannableString(value);
        sb.setSpan(new AbsoluteSizeSpan(20, true), 0, value.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
        sb.setSpan(new ForegroundColorSpan(Color.WHITE), 0, value.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
        tv.setText(sb);
        value = strs[1];
        sb = new SpannableString(value);
        sb.setSpan(new AbsoluteSizeSpan(12, true), 0, value.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
        sb.setSpan(new ForegroundColorSpan(Color.WHITE), 0, value.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
        tv.append(sb);
    }

    /**
     * 验证
     * @param value
     * @param info
     * @param etPassword
     * @return
     */
    public String checkValue(double value,TenderInfo info,String etPassword){
        if (value < info.floorm) { //下限限制，
            return "不能低于" + info.floorm;
        }
        if (value > info.upperm) { // 上限限制
            return "不能高于" + info.upperm;
        }
        if (!TextUtils.isEmpty(info.directional) && TextUtils.isEmpty(etPassword)) {
            return "定向标密码不能为空";
        }
        return "";
    }
}
